/****************************************************************
 * I am the AC 130 vs Pirate game. I allow the user to control an 
 * AC130 gunship in the hunt for Modern day pirates. The player  
 * will be allowed to roam free across a section of ocean/coastline.  
 * In the water there will be four types of vessels: Merchant  
 * ships that the player must protect, Pirate ships that the player  
 * must identify and destroy, Fishing boats that look like Pirate  
 * ships that the player must not destroy, and Friendly Navy ships  
 * that can capture pirates for extra points. Time permitting there  
 * may also be ground targets to attack. 
 *
 * Key elements of this project will be the Player/AC130, the Ships,  
 * the ShipAI system, the collision grid, the debris controller, the  
 * Ground/Water, Clouds, and scoring system. This project will make  
 * use of an external text file to store useful game parameters,  
 * thus allowing us to play balance the game without recompiling  
 * the executable. 
 *****************************************************************
 * I am the Bullet class I contain all the information for one bullet
 * in game. I am used to pass information about bullets to outside 
 * sources. I am basicaly a data containter with the ability to self 
 * update. I rely on my controller to do animation.
 *****************************************************************/

#include "Bullet.h"

/// I am the constructor. I place the bullet
Bullet::Bullet(){
	center = new Point;
	setInactive();
}

/// destructor
Bullet::~Bullet(){
	delete(center);
}

/// I am the update function. I move the position and decriment 
/// the timers. 
void Bullet::Update(){
		// don't update inactive bullets
	if(timeOut < 0) return;
		// update explosion animation

		// lower time till explosion 
		// when timeOut == 0 isBoom() will be true
	timeOut -= 1;

		// update Bullet allong seek path
	if(isTrack){
		helper->x = 0;
		helper->y = speed;
		helper->RotateBy(angle);
		center->x += helper->x;
		center->y += helper->y;
			// chainge angle to 
	}else{	// follow balistic path
		center->x += dx;
		center->y += dy;
		
	}


}

/// I am the active bullet checker I return true if this bullet
/// is currently active
bool  Bullet::isActive(){
	return (timeOut >= 0);
}

/// check if we are exploding and doing ground dammage
bool  Bullet::isBoom(){
	return (timeOut == 0);
}



/// I set all fields to inactive
void  Bullet::setInactive(){
	trackEx = NULL;
	dx = 0;
	dy = 0;
	angle = 0;
	timeOut = -1;
	loyalty = 0;
	type = 0;
		// bullet stats, needed by the classes that process damage

	speed = 5;
	dammage =5;
	killRad = 5;
	isTrack = false;
	blastMask = NULL;
}

